// 二进制字符串
// TextDecoder
let uint8Array = new Uint8Array([72, 101, 108, 108, 111])

let decoder = new TextDecoder('utf-8')
console.log(decoder.decode(uint8Array))

uint8Array = new Uint8Array([228, 189, 160, 229, 165, 189]);
console.log(decoder.decode(uint8Array))

uint8Array = new Uint8Array([0, 72, 101, 108, 108, 111, 0]);
// 该字符串位于中间
// 在不复制任何内容的前提下，创建一个新的视图
let binaryString = uint8Array.subarray(1, -1)
console.log(decoder.decode(uint8Array))


// TextEncoder
let encoder = new TextEncoder()
console.log(encoder.encode('你好'))
console.log(encoder.encode('你好').length)